// WebGrab.h: interface for the CWebGrab class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WEBGRAB_H__EC860D76_6E8E_48AF_9926_C9E0519126EB__INCLUDED_)
#define AFX_WEBGRAB_H__EC860D76_6E8E_48AF_9926_C9E0519126EB__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <afxinet.h>

class CWebGrabSession : public CInternetSession
{
// Construction
public:
	CWebGrabSession(LPCTSTR szAgentName);
	CWebGrabSession(LPCTSTR szAgentName, CWnd* pStatusWnd);
	virtual ~CWebGrabSession();
    void CommonConstruct();

// Operations
public:
    void SetStatus(LPCTSTR fmt, ...);

// Overrides
public:
	CString GetErrorMessage();

    virtual void OnStatusCallback(DWORD dwContext, DWORD dwInternetStatus, 
                                  LPVOID lpvStatusInformation, 
                                  DWORD dwStatusInformationLength);
protected:
	CString errorMessage;

};




//web grabber for fetching RSS feeds
class CWebGrab
{
public:
	CWebGrab();
	virtual ~CWebGrab();

// Operations
public:
    BOOL Initialise(LPCTSTR szAgentName = NULL);
 

    BOOL GetFile(LPCTSTR szURL,  LPCTSTR szFileName, 
                 LPCTSTR szAgentName = NULL);

	 void Close();
	// Overrides
public:
	CString GetRawHeaders();	
	CString GetErrorMessage();

	DWORD	GetPageStatusCode();
	SHORT   GetErrorCode();
	double  GetRate();

	void    SetUseProxy(bool use);
	void    SetProxy(LPCSTR proxy, WORD port,bool use=true);
	void    SetProxyPort(UINT port);
	void    SetProxyServer(LPCSTR server);
	void    SetTimeOut(DWORD timeOut);

	

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CWebGrab)
	//}}AFX_VIRTUAL

	// Generated message map functions
	//{{AFX_MSG(CWebGrab))
	//}}AFX_MSG

protected:
    CWebGrabSession* m_pSession;
	
	DWORD   m_timeOut;

private:
	double  m_transferRate;
	bool    m_useProxy;
	UINT    m_Port;
	DWORD	m_infoStatusCode;

	CString m_ErrorMessage;
	CString m_Proxy;
	CString	m_rawHeaders;
};

#endif // !defined(AFX_WEBGRAB_H__EC860D76_6E8E_48AF_9926_C9E0519126EB__INCLUDED_)
